home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / epath1.zip / EPATH1.ASM < prev    next >
Assembly Source File  |  1988-10-13  |  3KB  |  106 lines

  1. TITLE    EPATH    4-7-87    [9-5-88]
  2. ;from SIMTEL20's pd:<msdos.sysutl>EPATH.ARC
  3. ;- disassembled via ASMGEN
  4. ;- slightly tweaked.
  5. ;David Kirschbaum
  6. ;Toad Hall
  7. ;kirsch@braggvax.ARPA
  8.  
  9. LF    EQU    0AH
  10. CR    EQU    0DH
  11. ;
  12. CSeg    SEGMENT
  13.     ASSUME DS:CSeg, SS:CSeg ,CS:CSeg ,ES:CSeg
  14.  
  15. ;Define some labels in our PSP
  16.     org    2CH
  17. envseg    label    word            ;PSP environment strings pointer
  18.     org    80H
  19. pspcmd    label    byte            ;PSP cmd buffer
  20.  
  21.     ORG    100H
  22.  
  23. Epath:    MOV    BX,0368H        ;new stack pointer
  24.     MOV    SP,BX
  25.     ADD    BX,0FH            ;donno why he's doing all this
  26.     MOV    CL,4
  27.     SHR    BX,CL            ;convert required memory to paras
  28.     MOV    AH,4AH            ;modify allocated memory block
  29.     INT    21H
  30.  
  31. ;    MOV    AL,DS:80H        ;snarf PSP cmd length byte
  32.     mov    al,pspcmd        ;snarf PSP cmd length byte
  33.     OR    AL,AL            ;anything there?
  34.     JNZ    Move_Path_173        ;yep, go move into our buffer, finish
  35.  
  36.     PUSH    ES
  37. ;    MOV    ES,DS:2CH        ;PSP Environment strings pointer
  38.     mov    ES,envseg        ;PSP environment strings pointer
  39.     SUB    DI,DI            ;0 offset in environment strings
  40.     xor    ax,ax            ;get a handy 0        v1.1
  41.     mov    dx,5            ;handy constant        v1.1
  42. Lp11E:    MOV    SI,OFFSET pathbuff    ;seek for a 'PATH='
  43.     CLD                ;insure fwd
  44. ;    CMP    BYTE PTR ES:[DI],0
  45.     cmp    ES:[di],al        ;end of environment strings?
  46.     JZ    Show_Path_14D        ;yep, we're done
  47.     MOV    CX,dx    ;5        ;5 chars in 'PATH='
  48.     REPZ    CMPSB            ;found it?
  49.     JZ    Skp138            ;yep
  50. ;     SUB    AL,AL
  51.      MOV    CX,80H            ;skip over another 80H chars
  52.      REPNZ    SCASB            ;(bumping DI, I guess)
  53.      JMP    SHORT    Lp11E        ;and try again
  54.  
  55. Skp138:    MOV    BX,OFFSET pathbuffend
  56.     MOV    CX,dx    ;5        ;assume 'PATH=' 5 chars
  57. Lup13E:    MOV    AL,ES:[DI]        ;snarf environment string char
  58.     INC    DI            ;bump ptr
  59.     OR    AL,AL            ;terminating 0?
  60.     JZ    Show_Path_14D        ;yep, done
  61.      INC    CL            ;bump path length
  62.      MOV    [BX],AL            ;stuff char in our local buffer
  63.      INC    BX            ;bump local buffer ptr
  64.      JMP    SHORT    Lup13E
  65.  
  66. ;L014D      L0126 CJ  L0144 CJ
  67. Show_Path_14D:
  68.     MOV    pathlen_188,CL        ;save path length
  69.     MOV    WORD PTR [BX],0A0DH    ;terminate with CR/LF
  70.     INC    BX            ;bump past the CR/LF
  71.     INC    BX
  72.     MOV    BYTE PTR [BX],'$'    ;terminate DOS string
  73.     POP    ES
  74.     MOV    DX,OFFSET pathbuff    ;'PATH=', whatever
  75.     MOV    AH,9            ;display str
  76.     INT    21H
  77.     MOV    DX,OFFSET kbdbuf_187    ;kbd buffer
  78.     MOV    AH,0AH            ;buffered kbd input
  79.     INT    21H            ;(permit user to edit path)
  80. ;L0169      L0185 CJ
  81. Endit_169:
  82.     MOV    SI,OFFSET pathlen_188    ;DS:SI = vector to length byte
  83.                     ; preceding new path
  84.     INT    2EH            ;??? unknown int .. change path?
  85.     MOV    AX,4C00H        ;terminate process
  86.     INT    21H
  87.  
  88. ;L0173      L0115 CJ
  89. Move_Path_173:
  90.     MOV    CL,AL            ;path bytes to move
  91.     ADD    pathlen_188,AL
  92. ;    MOV    SI,81H            ;from PSP cmd buffer
  93.     mov    si,offset pspcmd+1    ;from PSP cmd buffer
  94.     MOV    DI,OFFSET pathbuffend    ;to our path buffer
  95.     REPZ    MOVSB            ;append path to 'PATH='
  96.     MOV    BYTE PTR ES:[DI],CR    ;terminate w/CR
  97.     JMP    SHORT    Endit_169    ;and terminate
  98.  
  99. kbdbuf_187    DB    50H        ;up to 50 chars in a path
  100. pathlen_188    DB    5        ;existing or new path
  101. pathbuff    DB    'PATH='        ;constant
  102. pathbuffend    DB    CR,'$'
  103.  
  104. CSeg    ENDS
  105.     END    Epath
  106.